home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * NSSDC/CDF CDF OBSOLETE interface (for V1.1 applications).
- *
- * Version 2.4, 28-Feb-92, ST Systems (STX)
- *
- * Modification history:
- *
- * V1.0 22-Jan-91, J Love Original version (for CDF V2.0).
- * V2.0 31-May-91, J Love Renamed (was CDF_V2_OBSOLETE_IF.C). Changed
- * for new CDF V2.1 internal structures and to
- * call INTERNAL i/f directly.
- * V2.1 12-Jun-91, J Love CDF_EPOCH made a data type.
- * V2.2 30-Jul-91, J Love Use 'CDFlib'. Added 'cdfdist.h' include.
- * Start CDFid's at 1 (rather than 0).
- * V2.3 24-Sep-91, J Love Modified for IBM-PC port.
- * V2.4 28-Feb-92, J Love CDF V2.2.
- *
- ******************************************************************************/
-
- #if defined(vms) /* THIS FILE IS ONLY USED ON VMS SYSTEMS */
-
- /******************************************************************************
- *
- * Notes:
- *
- * Because the CDF V1.1 Implementer's Guide had examples showing
- * character strings being passed into the CDF library without being enclosed
- * in %REF( ), it will be necessary to support both reference passing and
- * descriptor passing in these cases (when passing from FORTRAN to C, the
- * LINKer does not convert from descriptor passing to reference passing
- * automatically is it apparently did when passing a FORTRAN character string
- * to a FORTRAN byte array which occurred in CDF V1.1).
- *
- * Character strings being passed out from the CDF library are always
- * passed by reference. This is stated in the CDF V1.1 Implementer's Guide
- * and is shown in an example.
- *
- * Character string data is generally only used with attributes but it
- * can also be used with variables. It is assumed, however, that if a
- * variable is of data type STRING (CDF_CHAR), it will be passed in and out
- * by reference.
- *
- ******************************************************************************/
-
- #include "cdflib.h"
-
-
- /******************************************************************************
- * Macro to check CDFstatus from library call. Note the 'return' statement.
- ******************************************************************************/
-
- #define CHECKstatus(status,rcode) { \
- if (status < CDF_WARN) { \
- *rcode = CDFrcode (status); \
- return; \
- } \
- }
-
- /******************************************************************************
- * CDF_create.
- ******************************************************************************/
-
- void CDF_create (CDF_name, num_dims, dim_sizes, CDF_id, rcode)
- void *CDF_name; /* in: CDF name
- - in VMS, may be passed by
- reference or descriptor */
- long *num_dims; /* in: number of dimensions */
- long dim_sizes[]; /* in: dimension sizes */
- long *CDF_id; /* out: CDF identifier */
- long *rcode; /* out: CDF return code */
- {
- CDFid id;
- *rcode = CDFrcode
- (CDFlib (CREATE_, CDF_,
- DESCRtoREFnul(CDF_name,CDFV1_CDF_NAME_LEN),
- *num_dims, dim_sizes, &id,
- PUT_, CDF_ENCODING_, HOST_ENCODING,
- CDF_MAJORITY_, COL_MAJOR,
- NULL_));
- if (*rcode == CDFV1_OK) *rcode = CDFrcode (initializeCDFinfo (id));
- *CDF_id = id + 1;
- return;
- }
-
- /******************************************************************************
- * CDF_open.
- ******************************************************************************/
-
- void CDF_open (CDF_name, CDF_id, rcode)
- void *CDF_name; /* in: CDF name
- - in VMS, may be passed by
- reference or descriptor */
- long *CDF_id; /* out: CDF identifier */
- long *rcode; /* out: CDF return code */
- {
- CDFid id;
- *rcode = CDFrcode
- (CDFlib (OPEN_, CDF_,
- DESCRtoREFnul(CDF_name,CDFV1_CDF_NAME_LEN),
- &id,
- NULL_));
- if (*rcode == CDFV1_OK) *rcode = CDFrcode (initializeCDFinfo (id));
- *CDF_id = id + 1;
- return;
- }
-
- /******************************************************************************
- * CDF_inquire.
- ******************************************************************************/
-
- void CDF_inquire (id, num_dims, dim_sizes,
- num_recs, num_vars, num_attrs, rcode)
- long *id; /* in: CDF identifier */
- long *num_dims; /* out: number of dimensions */
- long dim_sizes[]; /* out: dimension sizes */
- long *num_recs; /* out: number of records */
- long *num_vars; /* out: number of variables */
- long *num_attrs; /* out: number of attributes */
- long *rcode; /* out: CDF return code */
- {
- long maxRec; /* maximum record number */
-
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- GET_, CDF_NUMDIMS_, num_dims,
- CDF_DIMSIZES_, dim_sizes,
- CDF_MAXREC_, &maxRec,
- CDF_NUMVARS_, num_vars,
- CDF_NUMATTRS_, num_attrs,
- NULL_));
- *num_recs = maxRec + 1;
- return;
- }
-
- /******************************************************************************
- * CDF_close.
- ******************************************************************************/
-
- void CDF_close (id, rcode)
- long *id; /* in: CDF identifier */
- long *rcode; /* out: CDF return code */
- {
- *rcode = CDFrcode (CDFlib (SELECT_, CDF_, *id - 1,
- CLOSE_, CDF_,
- NULL_));
- return;
- }
-
- /******************************************************************************
- * CDF_delete.
- ******************************************************************************/
-
- void CDF_delete (CDF_name, rcode)
- void *CDF_name; /* in: CDF name
- - in VMS, may be passed by
- reference or descriptor */
- long *rcode; /* out: CDF return code */
- {
- CDFid id;
- *rcode = CDFrcode
- (CDFlib (OPEN_, CDF_,
- DESCRtoREFnul(CDF_name,CDFV1_CDF_NAME_LEN),
- &id,
- DELETE_, CDF_,
- NULL_));
- return;
- }
-
- /******************************************************************************
- * CDF_attr_create.
- ******************************************************************************/
-
- void CDF_attr_create (id, attr_mnemonic, data_type, num_bytes, rcode)
- long *id; /* in: CDF identifier */
- void *attr_mnemonic; /* in: attribute name
- - in VMS may be passed by reference
- or descriptor */
- void *data_type; /* in: CDF Version 1 style data type
- - in VMS may be passed by reference
- or descriptor */
- long *num_bytes; /* in: number of bytes in data type (CDF
- Version 1 style) - only applies to
- STRING (CDF_CHAR) data type */
- long *rcode; /* out: CDF return code */
- {
- long dataType;
- long attrNum; /* C-style */
-
- dataType = CDFV2dataType (DESCRtoREFnul(data_type,CDFV1_DATA_TYPE_LEN));
-
- if (dataType == CDF_ILLEGAL_DATATYPE) {
- *rcode = CDFV1_DEFAULT_RCODE;
- return;
- }
-
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- CREATE_, ATTR_, DESCRtoREFnul(attr_mnemonic,
- CDFV1_ATTR_NAME_LEN),
- VARIABLE_SCOPE_ASSUMED, &attrNum,
- NULL_));
- if (*rcode == CDFV1_OK)
- *rcode = CDFrcode (putAttrInfo (*id - 1, attrNum, dataType,
- (dataType == CDF_CHAR ? *num_bytes : 1)));
-
- return;
- }
-
- /******************************************************************************
- * CDF_attr_inquire.
- ******************************************************************************/
-
- void CDF_attr_inquire (id, attr_id, attr_num, attr_mnemonic, data_type,
- num_bytes, num_entries, rcode)
- long *id; /* in: CDF identifier */
- void *attr_id; /* in: attribute identifier - could be
- 1) attribute number, or
- 2) attribute name - in VMS passed by
- reference or descriptor */
- long *attr_num; /* out: attribute number, FORTRAN-style */
- char *attr_mnemonic; /* out: attribute mnemonic - in VMS assumed to be
- passed out by reference as stated in CDF
- V1.1 Implementer's Guide */
- char *data_type; /* out: CDF Version 1 style data type,
- assumed to be passed out by reference as
- stated in CDF V1.1 Implementer's Guide */
- long *num_bytes; /* out: number of bytes in data type (CDF
- Version 1 style) */
- long *num_entries; /* out: number of entries for attribute - this was
- misleading because Version 1 actually
- returned the max. entry number (which was
- the number of entries if the entries used
- started at 1 and were contiguous) */
- long *rcode; /* out: CDF return code */
- {
-
- long attrType;
- char attrName[CDF_ATTR_NAME_LEN+1];
- long dataType;
- long numElements;
- long maxEntry;
- long i;
- CDFstatus status;
-
- /******************************************************************************
- * First determine attribute number (indexed starting at 1 for FORTRAN).
- ******************************************************************************/
-
- status = CDFV1attrNum (*id - 1, attr_id, attr_num);
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
-
- /******************************************************************************
- * Now inquire attribute.
- ******************************************************************************/
-
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- ATTR_, *attr_num - 1,
- GET_, ATTR_NAME_, attrName,
- ENTRY_DATATYPE_, &attrType,
- ATTR_MAXENTRY_, &maxEntry,
- NULL_));
-
- if (*rcode == CDFV1_OK)
- {
- /***************************************************************************
- * determine "number of entries" (Version 1 style)
- ***************************************************************************/
-
- *num_entries = maxEntry + 1;
-
- /***************************************************************************
- * copy attribute name padding with blanks if necessary (note that the name
- * may be truncated since CDF V2 names can be longer than CDF V1 names)
- ***************************************************************************/
-
- strncpy (attr_mnemonic, attrName, CDFV1_ATTR_NAME_LEN);
- for (i = strlen(attrName); i < CDFV1_ATTR_NAME_LEN; i++)
- attr_mnemonic[i] = ' ';
-
- /***************************************************************************
- * determine data_type and num_bytes
- ***************************************************************************/
-
- *rcode = CDFrcode (getAttrInfo (*id - 1, *attr_num - 1,
- &dataType, &numElements));
- if (*rcode == CDFV1_OK)
- CDFV1_data_type (dataType, numElements, data_type, num_bytes);
- }
-
- return;
- }
-
- /******************************************************************************
- * CDF_attr_put.
- ******************************************************************************/
-
- void CDF_attr_put (id, attr_id, entry_id, value, rcode)
- long *id; /* in: CDF identifier */
- void *attr_id; /* in: attribute identifier - could be
- 1) attribute number, or
- 2) attribute name - in VMS passed by
- reference or descriptor */
- void *entry_id; /* in: entry identifier - could be
- 1) entry/variable number, or
- 2) variable name - in VMS passed by
- reference or descriptor */
- void *value; /* in: attribute value, if STRING (CDF_CHAR)
- attribute, in VMS could be passed
- by reference or descriptor */
- long *rcode; /* out: CDF return code */
- {
- long attr_num; /* FORTRAN-style */
- long entry_num; /* FORTRAN-style */
- long attrNum; /* C-style */
- long entryNum; /* C-style */
- long entryDataType;
- long varDataType;
- char attrName[CDF_ATTR_NAME_LEN + 1];
- char varName[CDF_VAR_NAME_LEN + 1];
- long numElements;
- CDFstatus status;
-
- /******************************************************************************
- * Determine attribute number.
- ******************************************************************************/
-
- status = CDFV1attrNum (*id - 1, attr_id, &attr_num);
- CHECKstatus (status, rcode);
-
- attrNum = attr_num - 1;
-
- /******************************************************************************
- * Determine entry number.
- ******************************************************************************/
-
- status = CDFV1attrEntryNum (*id - 1, entry_id, &entry_num);
- CHECKstatus (status, rcode);
-
- entryNum = entry_num - 1;
-
- /******************************************************************************
- * Get info for this attribute. Check for incompatibility and get data type.
- ******************************************************************************/
-
- status = getAttrInfo (*id - 1, attrNum, &entryDataType, &numElements);
- CHECKstatus (status, rcode);
-
- /******************************************************************************
- * Check if data type for entry should be changed to CDF_EPOCH.
- ******************************************************************************/
-
- #if NSSDC_STANDARD
- status = CDFlib (SELECT_, CDF_, *id - 1,
- ATTR_, attrNum,
- GET_, ATTR_NAME_, attrName,
- NULL_);
- CHECKstatus (status, rcode);
-
- if ((strcmpITB(attrName,"VALIDMIN") == 0 ||
- strcmpITB(attrName,"VALIDMAX") == 0 ||
- strcmpITB(attrName,"SCALEMIN") == 0 ||
- strcmpITB(attrName,"SCALEMAX") == 0) &&
- (entryDataType == CDF_REAL8 || entryDataType == CDF_DOUBLE)) {
- status = CDFlib (SELECT_, CDF_, *id - 1,
- VAR_, entryNum,
- GET_, VAR_NAME_, varName,
- VAR_DATATYPE_, &varDataType,
- NULL_);
- if (status != NO_SUCH_VAR) {
- CHECKstatus (status, rcode);
-
- if (strcmpITB(varName,"EPOCH") == 0 &&
- (varDataType == CDF_REAL8 || varDataType == CDF_DOUBLE))
- entryDataType = CDF_EPOCH;
- }
- }
- #endif
-
- /******************************************************************************
- * Put to the attribute.
- ******************************************************************************/
-
- status = CDFlib (SELECT_, CDF_, *id - 1,
- ATTR_, attrNum,
- ENTRY_, entryNum,
- PUT_, ENTRY_DATA_, entryDataType, numElements,
- (entryDataType == CDF_CHAR ?
- DESCRtoREF(value) : value),
- NULL_);
- *rcode = CDFrcode (status);
-
- return;
- }
-
- /******************************************************************************
- * CDF_attr_get.
- ******************************************************************************/
-
- void CDF_attr_get (id, attr_id, entry_id, value, rcode)
- long *id; /* in: CDF identifier */
- void *attr_id; /* in: attribute identifier - could be
- 1) attribute number, or
- 2) attribute name - in VMS passed by
- reference or descriptor */
- void *entry_id; /* in: entry identifier - could be
- 1) entry/variable number, or
- 2) variable name - in VMS passed by
- reference or descriptor */
- void *value; /* out: attribute value, passing out is
- always done by reference (as stated in
- the CDF V1.1 Implementer's Guide) */
- long *rcode; /* out: CDF return code */
- {
- long attr_num; /* FORTRAN-style */
- long entry_num; /* FORTRAN-style */
- long attrNum; /* C-style */
- long entryNum; /* C-style */
- long dataType;
- long numElements;
- CDFstatus status;
-
- /******************************************************************************
- * Determine attribute number.
- ******************************************************************************/
-
- status = CDFV1attrNum (*id - 1, attr_id, &attr_num);
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
- else
- attrNum = attr_num - 1;
-
- /******************************************************************************
- * Determine entry number.
- ******************************************************************************/
-
- status = CDFV1attrEntryNum (*id - 1, entry_id, &entry_num);
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
- else
- entryNum = entry_num - 1;
-
- /******************************************************************************
- * Get info for this attribute.
- ******************************************************************************/
-
- *rcode = CDFrcode (getAttrInfo (*id - 1, attrNum,
- &dataType,
- &numElements)); /* check for incompatibility */
-
- /******************************************************************************
- * Get from the attribute. The value is assumed to be passed by reference as
- * stated in the CDF V1.1 Implementor's Guide.
- ******************************************************************************/
-
- if (*rcode == CDFV1_OK)
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- ATTR_, attrNum,
- ENTRY_, entryNum,
- GET_, ENTRY_DATA_, value,
- NULL_));
- return;
- }
-
-
- /******************************************************************************
- * CDF_var_create.
- ******************************************************************************/
-
- void CDF_var_create (id, var_mnemonic, data_type, num_bytes,
- record_variance, dim_variances, rcode)
- long *id; /* in: CDF identifier */
- void *var_mnemonic; /* in: attribute name
- - in VMS may be passed by reference
- or descriptor */
- void *data_type; /* in: CDF Version 1 style data type
- - in VMS may be passed by reference
- or descriptor */
- long *num_bytes; /* in: number of bytes in data type (CDF
- Version 1 style) - only applies to
- STRING (CDF_CHAR) data type */
- long *record_variance; /* in: record variance */
- long dim_variances[]; /* in: dimension variances */
- long *rcode; /* out: CDF return code */
- {
- long varNum; /* C-style */
- long dataType;
- char *varName;
- CDFstatus status;
-
- dataType = CDFV2dataType (DESCRtoREFnul(data_type,CDFV1_DATA_TYPE_LEN));
- varName = DESCRtoREFnul (var_mnemonic, CDFV1_VAR_NAME_LEN);
-
- #if NSSDC_STANDARD
- if (strcmpITB(varName,"EPOCH") == 0 && dataType == CDF_REAL8)
- dataType = CDF_EPOCH;
- #endif
-
- status = CDFlib (SELECT_, CDF_, *id - 1,
- CREATE_, VAR_, varName, dataType,
- (dataType == CDF_CHAR ? *num_bytes : 1),
- *record_variance, dim_variances, &varNum,
- NULL_);
- *rcode = CDFrcode (status);
- return;
- }
-
- /******************************************************************************
- * CDF_var_inquire.
- ******************************************************************************/
-
- void CDF_var_inquire (id, var_id, var_num, var_mnemonic, data_type, num_bytes,
- record_variance, dim_variances, rcode)
- long *id; /* in: CDF identifier */
- void *var_id; /* in: variable identifier - could be
- 1) variable number, or
- 2) variable name - in VMS passed by
- reference or descriptor */
- long *var_num; /* out: variable number, FORTRAN-style */
- char *var_mnemonic; /* out: variable mnemonic - in VMS assumed to be
- passed out by reference as stated in CDF
- V1.1 Implementer's Guide */
- char *data_type; /* out: CDF Version 1 style data type,
- assumed to be passed out by reference as
- stated in CDF V1.1 Implementer's Guide */
- long *num_bytes; /* out: number of bytes in data type (CDF
- Version 1 style) */
- long *record_variance; /* out: record variance */
- long dim_variances[]; /* out: dimension variances */
- long *rcode; /* out: CDF return code */
- {
- char varName[CDF_VAR_NAME_LEN+1];
- long dataType;
- long numElements;
- long i;
- CDFstatus status;
-
- /******************************************************************************
- * Determine variable number.
- ******************************************************************************/
-
- status = CDFV1varNum (*id - 1, var_id, var_num);
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
-
- /******************************************************************************
- * Inquire variable.
- ******************************************************************************/
-
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- VAR_, *var_num - 1,
- GET_, VAR_NAME_, varName,
- VAR_DATATYPE_, &dataType,
- VAR_NUMELEMS_, &numElements,
- VAR_RECVARY_, record_variance,
- VAR_DIMVARYS_, dim_variances,
- NULL_));
-
- if (*rcode == CDFV1_OK)
- {
- /***************************************************************************
- * copy variable name padding with blanks if necessary (note that the name
- * may be truncated since CDF V2 names can be longer than CDF V1 names)
- ***************************************************************************/
-
- strncpy (var_mnemonic, varName, CDFV1_VAR_NAME_LEN);
-
- for (i = strlen(varName); i < CDFV1_VAR_NAME_LEN; i++)
- var_mnemonic[i] = ' ';
-
- /***************************************************************************
- * determine data_type and num_bytes
- ***************************************************************************/
-
- CDFV1_data_type (dataType, numElements, data_type, num_bytes);
- }
-
- return;
- }
-
- /******************************************************************************
- * CDF_var_put.
- ******************************************************************************/
-
- void CDF_var_put (id, var_id, record_num, indices, value, rcode)
- long *id; /* in: CDF identifier */
- void *var_id; /* in: variable identifier - could be
- 1) variable number, or
- 2) variable name - in VMS passed by
- reference or descriptor */
- long *record_num; /* in: record number (CDF V1 style, starts
- at 1) */
- long indices[]; /* in: dimension indices (CDF V1 style,
- each start at 1) */
- void *value; /* in: variable value, for now always
- assume passed by reference (this
- assumption is not made for an
- attribute put) */
- long *rcode; /* out: CDF return code */
- {
- long dim_n;
- long Cindices[CDF_MAX_DIMS];
- long varNum; /* C-style */
- long recNum; /* C-style */
- long recVary;
- long numDims;
- long dimVarys[CDF_MAX_DIMS];
- long var_num; /* FORTRAN-style */
- long rec_num; /* FORTRAN-style */
- CDFstatus status;
-
- /******************************************************************************
- * Determine variable number.
- ******************************************************************************/
-
- status = CDFV1varNum (*id - 1, var_id, &var_num);
-
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
- else
- varNum = var_num - 1;
-
- /******************************************************************************
- * Calculate record number and indices. Setting the record number and/or
- * indices to 0 if the variances are FALSE (NOVARY) is done because some
- * applications didn't pass in valid values. This way the V2.x library won't
- * return an error.
- ******************************************************************************/
-
- status = CDFlib (SELECT_, CDF_, *id - 1,
- VAR_, varNum,
- GET_, CDF_NUMDIMS_, &numDims,
- VAR_RECVARY_, &recVary,
- VAR_DIMVARYS_, dimVarys,
- NULL_);
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
-
- if (recVary)
- recNum = *record_num - 1;
- else
- recNum = 0;
-
- for (dim_n = 0; dim_n < numDims; dim_n++)
- if (dimVarys[dim_n])
- Cindices[dim_n] = indices[dim_n] - 1; /* index from 0 for CDF V2 */
- else
- Cindices[dim_n] = 0;
-
- /******************************************************************************
- * Put to variable.
- ******************************************************************************/
-
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- CDF_RECNUMBER_, recNum,
- CDF_DIMINDICES_, Cindices,
- PUT_, VAR_DATA_, value, /* by REF always */
- NULL_));
- return;
- }
-
- /******************************************************************************
- * CDF_var_get.
- ******************************************************************************/
-
- void CDF_var_get (id, var_id, record_num, indices, value, rcode)
- long *id; /* in: CDF identifier */
- void *var_id; /* in: variable identifier - could be
- 1) variable number, or
- 2) variable name - in VMS passed by
- reference or descriptor */
- long *record_num; /* in: record number (CDF V1 style, starts
- at 1) */
- long indices[]; /* in: dimension indices (CDF V1 style,
- each start at 1) */
- void *value; /* out: variable value, always assumed
- passed out by reference */
- long *rcode; /* out: CDF return code */
- {
- long dim_n;
- long Cindices[CDF_MAX_DIMS]; /* C-style */
- long varNum; /* C-style */
- long recNum; /* C-style */
- long numDims;
- long recVary;
- long dimVarys[CDF_MAX_DIMS];
- long var_num; /* FORTRAN-style */
- CDFstatus status;
-
- /******************************************************************************
- * Determine variable number.
- ******************************************************************************/
-
- status = CDFV1varNum (*id - 1, var_id, &var_num);
-
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
- else
- varNum = var_num - 1;
-
- /******************************************************************************
- * Calculate record number and indices. Setting the record number and/or
- * indices to 0 if the variances are FALSE (NOVARY) is done because some
- * applications didn't pass in valid values. This way the V2.x library won't
- * return an error.
- ******************************************************************************/
-
- status = CDFlib (SELECT_, CDF_, *id - 1,
- VAR_, varNum,
- GET_, CDF_NUMDIMS_, &numDims,
- VAR_RECVARY_, &recVary,
- VAR_DIMVARYS_, dimVarys,
- NULL_);
- if (status < CDF_WARN) {
- *rcode = CDFrcode (status);
- return;
- }
-
- if (recVary)
- recNum = *record_num - 1;
- else
- recNum = 0;
-
- for (dim_n = 0; dim_n < numDims; dim_n++)
- if (dimVarys[dim_n])
- Cindices[dim_n] = indices[dim_n] - 1; /* index from 0 for CDF V2 */
- else
- Cindices[dim_n] = 0;
-
- /******************************************************************************
- * Get from variable.
- ******************************************************************************/
-
- *rcode = CDFrcode
- (CDFlib (SELECT_, CDF_, *id - 1,
- CDF_RECNUMBER_, recNum,
- CDF_DIMINDICES_, Cindices,
- GET_, VAR_DATA_, value, /* by REF always */
- NULL_));
- return;
- }
-
- /******************************************************************************
- * CDFV2dataType.
- * Determine CDF V2 style data type from a CDF V1 style data type.
- ******************************************************************************/
-
- long CDFV2dataType (V1_data_type)
- char *V1_data_type;
- {
-
- if (strncmp(V1_data_type,"BYTE",4) == 0) return CDF_BYTE;
- if (strncmp(V1_data_type,"INT*2",5) == 0) return CDF_INT2;
- if (strncmp(V1_data_type,"INT*4",5) == 0) return CDF_INT4;
- if (strncmp(V1_data_type,"REAL*4",6) == 0) return CDF_REAL4;
- if (strncmp(V1_data_type,"REAL*8",6) == 0) return CDF_REAL8;
- if (strncmp(V1_data_type,"STRING",6) == 0) return CDF_CHAR;
-
- return CDF_ILLEGAL_DATATYPE;
- }
-
- /******************************************************************************
- * CDFV1varNum.
- * Determine a CDF V1 style variable number given a CDF V1 style variable
- * id which could be either a number or a name (in VMS, passed by either
- * reference or descriptor).
- ******************************************************************************/
-
- CDFstatus CDFV1varNum (id, ptr, var_num)
- CDFid id;
- void *ptr;
- long *var_num;
- {
- long varNum; /* C-style variable number */
-
- memmove (var_num, ptr, sizeof(long));
-
- if (*var_num <= CDF_MAX_VARS)
- return CDF_OK; /* assumed to be a number already
- - this could fail if a variable
- name of only 1 character was
- passed in as the variable id */
- else
- {
- CDFstatus status;
- status = CDFlib (SELECT_, CDF_, id,
- GET_, VAR_NUMBER_, DESCRtoREFnul(ptr,CDFV1_VAR_NAME_LEN),
- &varNum,
- NULL_);
- *var_num = varNum + 1;
- return status;
- }
- }
-
- /******************************************************************************
- * CDFV1attrNum.
- * Determine a CDF V1 style attribute number given a CDF V1 style attribute
- * id which could be either a number or a name (in VMS passed by either
- * reference or descriptor).
- ******************************************************************************/
-
- CDFstatus CDFV1attrNum (id, ptr, attr_num)
- CDFid id;
- void *ptr;
- long *attr_num;
- {
- long attrNum; /* C-style attribute number */
-
- memmove (attr_num, ptr, sizeof(long));
-
- if (*attr_num <= TWO_BLANKS)
- return CDF_OK; /* assumed to be a number already
- - this could fail if an attribute
- name of only 1 character was
- passed in as the attribute id */
- else
- {
- CDFstatus status;
- status = CDFlib (SELECT_, CDF_, id,
- GET_, ATTR_NUMBER_, DESCRtoREFnul(ptr,CDFV1_ATTR_NAME_LEN),
- &attrNum,
- NULL_);
- *attr_num = attrNum + 1;
- return status;
- }
- }
-
- /******************************************************************************
- * CDFV1attrEntryNum.
- * Determine a CDF V1 style attribute entry number given a CDF V1 style
- * entry id which could be either a variable number/global entry number or a
- * variable name (in VMS passed by either reference or descriptor).
- ******************************************************************************/
-
- CDFstatus CDFV1attrEntryNum (id, ptr, entry_num)
- CDFid id;
- void *ptr;
- long *entry_num;
- {
- long varNum; /* C-style variable number */
-
- memmove (entry_num, ptr, sizeof(long));
-
- if (*entry_num <= TWO_BLANKS)
- return CDF_OK; /* assumed to be a number already
- - this could fail if a variable
- name of only 1 character was
- passed in as the entry id */
- else
- {
- CDFstatus status;
- status = CDFlib (SELECT_, CDF_, id,
- GET_, VAR_NUMBER_, DESCRtoREFnul(ptr,CDFV1_VAR_NAME_LEN),
- &varNum,
- NULL_);
- *entry_num = varNum + 1;
- return status;
- }
- }
-
- /******************************************************************************
- * CDFrcode.
- * Translate CDF V2 status code to CDF V1 return code.
- ******************************************************************************/
-
- long CDFrcode (Status)
- CDFstatus Status;
- {
- if (Status < CDF_WARN)
- switch (Status) {
- case NO_SUCH_VAR: return CDFV1_NO_SUCH_VAR;
- case NO_SUCH_ATTR: return CDFV1_NO_SUCH_ATTR;
- case NO_SUCH_ENTRY: return CDFV1_NO_SUCH_ATTR_ENTRY;
- default: return CDFV1_DEFAULT_RCODE;
- }
- else
- return CDFV1_OK;
- }
-
- /******************************************************************************
- * Determine CDF V1 style data type and number of bytes.
- ******************************************************************************/
-
- void CDFV1_data_type (dataType, STRING_num_bytes, data_type, num_bytes)
- long dataType; /* CDF V2 style data type */
- long STRING_num_bytes; /* number of bytes if of "string" data type,
- otherwise ignored */
- char *data_type; /* CDF V1 style data type */
- long *num_bytes; /* CDF V1 style number of bytes */
- {
-
- switch (dataType)
- {
- case CDF_BYTE:
- case CDF_INT1:
- strncpy (data_type, "BYTE ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = 1;
- break;
-
- case CDF_INT2:
- strncpy (data_type, "INT*2 ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = 2;
- break;
-
- case CDF_INT4:
- strncpy (data_type, "INT*4 ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = 4;
- break;
-
- case CDF_REAL4:
- case CDF_FLOAT:
- strncpy (data_type, "REAL*4 ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = 4;
- break;
-
- case CDF_REAL8:
- case CDF_DOUBLE:
- case CDF_EPOCH:
- strncpy (data_type, "REAL*8 ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = 8;
- break;
-
- case CDF_CHAR:
- case CDF_UCHAR:
- strncpy (data_type, "STRING ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = STRING_num_bytes;
- break;
-
- default:
- strncpy (data_type, "ILLEGAL ", CDFV1_DATA_TYPE_LEN);
- *num_bytes = 0;
- break;
- }
-
- return;
- }
-
- #endif
-